package at.pervasive.mp3player.gui;

import java.io.File;
import java.util.LinkedList;
import java.util.List;

import javax.swing.AbstractListModel;

public class PlaylistModel extends AbstractListModel
{

	private List<File> entries;

	public PlaylistModel()
	{
		super();
		entries = new LinkedList<File>();
	}

	public void addFiles(List<File> files)
	{
		entries.addAll(files);
		fireContentsChanged(this, 0, getSize());
	}

	public void removeFiles(List<File> files)
	{
		entries.removeAll(files);
		fireContentsChanged(this, 0, getSize());
	}

	@Override
	public Object getElementAt(int index)
	{
		return entries.get(index);
	}

	@Override
	public int getSize()
	{
		return entries.size();
	}

	public void setFiles(List<File> mp3Files)
	{
		this.entries.clear();
		this.entries.addAll(mp3Files);

		fireContentsChanged(this, 0, getSize());
	}

}
